package com.desay.pangoo.itmt.feign;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import com.alibaba.fastjson.JSONObject;

/**
 * 获取车辆信息
 *
 * @author uidq1163
 */
@FeignClient(name = "FeiShu", url = "https://open.feishu.cn/open-apis")
public interface FeishuRequestService {

	/**
	 * { "app_id": "cli_slkdjalasdkjasd", "app_secret": "dskLLdkasdjlasdKK" }
	 *
	 * @param body
	 * @return
	 */
	@PostMapping(value = "/auth/v3/tenant_access_token/internal")
	ResponseEntity<Object> getAccessToken(@RequestBody JSONObject body);

	/**
	 * { "receive_id": "uidq1163", "msg_type": "text", "content":
	 * "{\"text\":\"消息内容\"}", "uuid": "a0d69e20-1dd1-458b-k525-dfeca4015204" }
	 *
	 * @param body
	 * @param token
	 *            “Bearer t-7f1bcd13fc57d46bac21793a18e560”
	 * @return
	 */
	@PostMapping(value = "/im/v1/messages?receive_id_type=user_id")
	ResponseEntity<Object> pushMessage(@RequestHeader(name = "Authorization") String token,
			@RequestBody JSONObject body);

	/**
	 * 推送任务
	 *
	 * @param token
	 * @param body
	 * @return
	 */
	@PostMapping(value = "/task/v1/tasks?user_id_type=user_id")
	ResponseEntity<Object> pushTask(@RequestHeader(name = "Authorization") String token, @RequestBody JSONObject body);

	/**
	 * 
	 * 更新任务完成时间 { "task": { "completed_at": "1718939520662" }, "update_fields":
	 * [ "completed_at" ] }
	 * 
	 * @param token
	 * @param taskId
	 * @param body
	 * @return
	 */
	@PatchMapping(value = "/task/v2/tasks/{taskId}")
	ResponseEntity<Object> updateTask(@RequestHeader(name = "Authorization") String token,
			@PathVariable(name = "taskId") String taskId, @RequestBody JSONObject body);

	/**
	 * 新增提醒时间 { "relative_fire_minute": 240 }
	 *
	 * @param token
	 * @param taskId
	 * @param body
	 * @return
	 */
	@PostMapping(value = "/task/v1/tasks/{taskId}/reminders")
	ResponseEntity<Object> remindersTask(@RequestHeader(name = "Authorization") String token,
			@PathVariable(name = "taskId") String taskId, @RequestBody JSONObject body);

	/**
	 * 创建日程 { "summary":"hsy-test-2 系统自动创建日程", "start_time": { "timestamp":
	 * "1694509168" }, "end_time": { "timestamp": "1694515716" },
	 * "need_notification":true, "attendee_ability": "can_modify_event" }
	 * 
	 * @param token
	 * @param calendarId
	 *            feishu.cn_GeDVa5JOfsSYxg79Y43W0d@group.calendar.feishu.cn
	 * @param body
	 * @return
	 */
	@PostMapping(value = "/calendar/v4/calendars/{calendar_id}/events?user_id_type=user_id")
	ResponseEntity<Object> createCalendars(@RequestHeader(name = "Authorization") String token,
			@PathVariable(name = "calendar_id") String calendarId, @RequestBody JSONObject body);

	/**
	 * 添加参会人员日程 { "attendees": [ { "type": "user", "is_optional": false,
	 * "user_id": "uidq1345", "operate_id": "uidq1163" } ], "need_notification":
	 * true, }
	 * 
	 * @param token
	 * @param calendarId
	 *            feishu.cn_GeDVa5JOfsSYxg79Y43W0d@group.calendar.feishu.cn
	 * @param eventId
	 * @param body
	 * @return
	 */
	@PostMapping(value = "/calendar/v4/calendars/{calendar_id}/events/{event_id}/attendees?user_id_type=user_id")
	ResponseEntity<Object> updateCalendars(@RequestHeader(name = "Authorization") String token,
			@PathVariable(name = "calendar_id") String calendarId, @PathVariable(name = "event_id") String eventId,
			@RequestBody JSONObject body);
}
